Barcode scanning on smart devices can be an effective way to scan a barcode. However the optics on these systems are usually optimized for photography and rely on an autofocus routine to get the image into focus. When scanning barcodes, a slightly out of focus image combined with excessive motion can result in an image that is too blurry to decode. It is therefore desirable to have a good focus to assure accuracy of reading the barcode.